package com.hongyuan.sellfitness.ui.home.view_mode;

import android.graphics.drawable.Drawable;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.databinding.ObservableField;

import com.hongyuan.mvvmhabitx.binding.command.BindingAction;
import com.hongyuan.mvvmhabitx.binding.command.BindingCommand;
import com.hongyuan.sellfitness.R;
import com.hongyuan.sellfitness.base.ItemViewModel;
import com.hongyuan.sellfitness.ui.home.beans.GroupClassTopBean;

public class GroupClassTopItemViewModel extends ItemViewModel<GroupClassViewModel> {

    public ObservableField<GroupClassTopBean> entity = new ObservableField<>();

    public Drawable drawableImg;

    public GroupClassTopItemViewModel(@NonNull GroupClassViewModel viewModel, GroupClassTopBean bean) {
        super(viewModel);
        entity.set(bean);
        if(bean.isSelect()){
            drawableImg = ContextCompat.getDrawable(viewModel.getApplication(), R.mipmap.vtwo_group_class_time_select_img);
        }else{
            drawableImg = null;
        }
    }

    //条目的点击事件
    public BindingCommand itemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            viewModel.changeList(GroupClassTopItemViewModel.this);
        }
    });
}
